﻿
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>综合治税统计报表</title>
    <link href="~/Content/LayerUI/src/css/layui.css" rel="stylesheet" />
    <link href="~/Content/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/Styles/zor.css" rel="stylesheet" />
    <!-- 框架必要 -->
    <script src="~/Content/Scripts/jquery/jquery-1.9.1.min.js"></script>
    <script src="~/Content/Scripts/learunui-framework.js"></script>
    <script src="~/Content/Scripts/Zor_AJax.js"></script>
    <!-- 消息提示 -->
    <script language='javascript' src='~/Content/layer/layer.js'></script>
    <!-- 日期选择器 -->
    <script src="~/Content/laydate/laydate.js"></script>
</head>
<body>

    <div class="layui-tab layui-tab-brief main-tab-container">
      
        <div class="col-sm-12 ct-padding">         
            <button id="btnSearch" class="layui-btn  layui-btn-normal layui-btn-small"><span class="glyphicon glyphicon-search"></span>查询 </button>
            <button id="btnExport" class="layui-btn layui-btn-springgreen layui-btn-small"><span class="glyphicon glyphicon-share"></span> 导出 </button>
        </div>
           
        <div class="col-sm-12  layui-tab-content">
            <div class="mail-box" style="overflow-x:scroll;white-space:nowrap;">
                <table class="layui-table" lay-skin="line">
                    <thead>
                        <tr>
                            <th hidden>街办ID</th>
                            <th>单位名称</th>
                            <th>住宅数</th>
                            <th>非住宅数</th>
                            <th>受理户数</th>
                            <th>缴税户数</th>
                            <th>增值税(元)</th>
                            <th>房产税(元)</th>
                            <th>个人所得税(元)</th>
                            <th>城建税(元)</th>
                            <th>教育附加税(元)</th>
                            <th>地方教育附加税(元)</th>
                            <th>印花税(元)</th>
                            <th>水利基金(元)</th>
                            <th>小计(元)</th>
                        </tr>
                    </thead>
                    <tbody id="accordion"></tbody>
                </table>
            </div>   
         </div>
    </div>
    <!--查询模态-->
    <div id="ModalSearch" data-backdrop="static" style="display:none;">

        <div class="layui-form-item">
            <label class="col-sm-2 layui-form-label">起始时间：</label>
            <div class="col-sm-4">
                <input id="Search_StartTime" name="StartTime" type="text" class="laydate-icon  form-control layer-date">
            </div>
            <label class="col-sm-2 layui-form-label">结束时间：</label>
            <div class="col-sm-4">
                <input id="Search_EndTime" name="EndTime" type="text" class="laydate-icon form-control layer-date">
            </div>
        </div>
        <div class="box-footer">
            <button id="btnSubmit" class="layui-btn layui-btn-normal layui-btn-small pull-right">
                <i class="fa fa-search"></i>查询
            </button>
        </div>

    </div>
        <!-- 街道办导出模态 -->
        <form action="/ReportForms/GIS_StatisticalTableMeg" enctype="multipart/form-data" method="post" id="formDownload">
            <div id="exportHtml" style="display:none;">
                <div class="eh_wrap">
                    <div class="eh_head">
                        <p style="">请选择您要导出的数据列</p>
                    </div>
                    <table width="100%" cellpadding="5" cellspacing="0">
                        <tr>
                            <td><input id="StreetOffice" type="checkbox" value="单位名称" name="chk_list" checked="checked" /><label>单位名称</label></td>
                           
                        </tr>
                        <tr>
                            <td><input id="StreetOfficeHousNumber" type="checkbox" value="住宅数" name="chk_list" checked="checked" /><label>住宅数</label></td>
                            <td><input id="StreetOfficeShopNumber" type="checkbox" value="非住宅数" name="chk_list" checked="checked" /><label>非住宅数</label></td>
                            <td><input id="ANumber" type="checkbox" value="受理户数" name="chk_list" checked="checked" /><label>受理户数</label></td>
                            <td><input id="PNumber" type="checkbox" value="缴税户数" name="chk_list" checked="checked" /><label>缴税户数</label></td>
                            
                        </tr>
                        <tr>
                            <td><input id="Zzs" type="checkbox" value="增值税" name="chk_list" checked="checked" /><label>增值税</label></td>
                            <td><input id="Fcs" type="checkbox" value="房产税" name="chk_list" checked="checked" /><label>房产税</label></td>
                            <td><input id="Grsds" type="checkbox" value="个人所得税" name="chk_list" checked="checked" /><label>个人所得税</label></td>
                            <td><input id="Cjs" type="checkbox" value="城建税" name="chk_list" checked="checked" /><label>城建税</label></td>
                        </tr>
                        <tr>
                            <td><input id="Jyffj" type="checkbox" value="教育附加税" name="chk_list" checked="checked" /><label>教育附加税</label></td>
                            <td><input id="Dfjyfj" type="checkbox" value="地方教育附加税" name="chk_list" checked="checked" /><label>地方教育附加税</label></td>
                            <td><input id="Yhs" type="checkbox" value="印花税" name="chk_list" checked="checked" /><label>印花税</label></td>
                            <td><input id="Sljj" type="checkbox" value="水利基金" name="chk_list" checked="checked" /><label>水利基金</label></td>
                        </tr>
                        <tr>
                            
                            <td><input id="xiaoji" type="checkbox" value="小计" name="chk_list" checked="checked" /><label>小计</label></td>
                        </tr>                      
                    </table>
                    <div class="box-footer">
                        <button type="submit" id="btnExportSure" class="layui-btn layui-btn-springgreen layui-btn-small pull-right" style=" margin-right:30px;">
                            <i class="fa fa-repeat"></i>导出
                        </button>
                        <input type="hidden" id="GIS_StatisticalTableMeg" name="GIS_StatisticalTableMeg" value="" />
                        <input type="hidden" id="where" name="where" value="" />
                    </div>
                </div>
            </div>
        </form>

    <!-- 社区导出模态 -->
    <form action="/ReportForms/GIS_CommunityStatisticalTableMeg" enctype="multipart/form-data" method="post" id="CommunitformDownload">
        <div id="CommunityexportHtml" style="display:none;">
            <div class="eh_wrap">
                <div class="eh_head">
                    <p style="">请选择您要导出的数据列</p>
                </div>
                <table width="100%" cellpadding="5" cellspacing="0">
                    <tr>
                        <td><input id="Community" type="checkbox" value="社区名称" name="Communitychk_list" checked="checked" /><label>社区名称</label></td>

                    </tr>
                    <tr>
                        <td><input id="CommunityHousNumber" type="checkbox" value="住宅数" name="Communitychk_list" checked="checked" /><label>住宅数</label></td>
                        <td><input id="CommunityShopNumber" type="checkbox" value="非住宅数" name="Communitychk_list" checked="checked" /><label>非住宅数</label></td>
                        <td><input id="CommunityANumber" type="checkbox" value="受理户数" name="Communitychk_list" checked="checked" /><label>受理户数</label></td>
                        <td><input id="CommunityPNumber" type="checkbox" value="缴税户数" name="Communitychk_list" checked="checked" /><label>缴税户数</label></td>

                    </tr>
                    <tr>
                        <td><input id="CommunityZzs" type="checkbox" value="增值税" name="Communitychk_list" checked="checked" /><label>增值税</label></td>
                        <td><input id="CommunityFcs" type="checkbox" value="房产税" name="Communitychk_list" checked="checked" /><label>房产税</label></td>
                        <td><input id="CommunityGrsds" type="checkbox" value="个人所得税" name="Communitychk_list" checked="checked" /><label>个人所得税</label></td>
                        <td><input id="CommunityCjs" type="checkbox" value="城建税" name="Communitychk_list" checked="checked" /><label>城建税</label></td>
                    </tr>
                    <tr>
                        <td><input id="CommunityJyffj" type="checkbox" value="教育附加税" name="Communitychk_list" checked="checked" /><label>教育附加税</label></td>
                        <td><input id="CommunityDfjyfj" type="checkbox" value="地方教育附加税" name="Communitychk_list" checked="checked" /><label>地方教育附加税</label></td>
                        <td><input id="CommunityYhs" type="checkbox" value="印花税" name="Communitychk_list" checked="checked" /><label>印花税</label></td>
                        <td><input id="CommunitySljj" type="checkbox" value="水利基金" name="Communitychk_list" checked="checked" /><label>水利基金</label></td>
                    </tr>
                    <tr>

                        <td><input id="Communityxiaoji" type="checkbox" value="小计" name="Communitychk_list" checked="checked" /><label>小计</label></td>
                    </tr>
                </table>
                <div class="box-footer">
                    <button type="submit" id="btnCommunityExportSure" class="layui-btn layui-btn-springgreen layui-btn-small pull-right" style=" margin-right:30px;">
                        <i class="fa fa-repeat"></i>导出
                    </button>
                    <input type="hidden" id="GIS_CommunityStatisticalTableMeg" name="GIS_CommunityStatisticalTableMeg" value="" />
                    <input type="hidden" id="Communitywhere" name="Communitywhere" value="" />               
                </div>
            </div>
        </div>
    </form>
     <!-- 社区级综合治税一览表 -->
    <div id="CommunityModal" style="display: none;padding: 20px;">
        <div class="col-sm-12 ct-padding">
            <button id="btnCommunityExport" class="layui-btn layui-btn-springgreen layui-btn-small"><span class="glyphicon glyphicon-share"></span> 导出 </button>
        </div>

        <div class="col-sm-12  layui-tab-content">
            <div class="mail-box" style="overflow-x:scroll;white-space:nowrap;">
                <table class="table table-hover table-mail">
                    <thead>
                        <tr>
                            <th>编号</th>
                            <th>社区名称</th>
                            <th>住宅数</th>
                            <th>非住宅数</th>
                            <th>受理户数</th>
                            <th>缴税户数</th>
                            <th>增值税</th>
                            <th>房产税</th>
                            <th>个人所得税</th>
                            <th>城建税</th>
                            <th>教育附加税</th>
                            <th>地方教育附加税</th>
                            <th>印花税</th>
                            <th>水利基金</th>
                            <th>小计</th>
                        </tr>
                    </thead>
                    <tbody id="accordion1"></tbody>
                </table>
                <div class="box-footer" hidden>
                    <input type="hidden" id="HiddenDate" name="HiddenDate" value="" />
                </div>
            </div>
        </div>
    </div>
</body>
</html>
<script>

    //页面加载时执行列表展示
    $(document).ready(function () {
        StreetOfficeInfo();
    });
    /*街道办税收加载*/
    var inputStateDate = "";
    var inputEndDate = "";
    function StreetOfficeInfo(inputStateDate, inputEndDate) {
        var html = "";
        getAjax("/ReportForms/LoadStreetOfficeInfo", { "stateDate": inputStateDate, "endDate": inputEndDate }, function (data) {
            accordionJson = eval("(" + data + ")");
            var SoHousNumber = 0, SoShopNumber = 0, ANumber = 0, PNumber = 0, Zzs = 0, Fcs = 0, Grsds = 0, Cjs = 0, Jyffj = 0, Dfjyfj = 0, Yhs = 0, Sljj = 0, xiaoji=0;
            $.each(accordionJson, function (i) {
                html += "<tr onclick='openCommunityModal(" + accordionJson[i].StreetOffice_Id + ")'>";
                html += "<td hidden>" + accordionJson[i].StreetOffice_Id + "</td>";
                html += "<td>" + accordionJson[i].StreetOffice + "</td>";
                html += "<td>" + accordionJson[i].StreetOfficeHousNumber + "</td>";
                html += "<td>" + accordionJson[i].StreetOfficeShopNumber + "</td>";
                html += "<td>" + accordionJson[i].ANumber + "</td>";
                html += "<td>" + accordionJson[i].PNumber + "</td>";
                html += "<td>" + accordionJson[i].Zzs + "</td>";
                html += "<td>" + accordionJson[i].Fcs + "</td>";
                html += "<td>" + accordionJson[i].Grsds + "</td>";
                html += "<td>" + accordionJson[i].Cjs+ "</td>";
                html += "<td>" + accordionJson[i].Jyffj + "</td>";
                html += "<td>" + accordionJson[i].Dfjyfj + "</td>";
                html += "<td>" + accordionJson[i].Yhs+ "</td>";
                html += "<td>" + accordionJson[i].Sljj + "</td>";
                html += "<td>" + accordionJson[i].xiaoji + "</td>";
                html += "</tr>";
                SoHousNumber += Number(accordionJson[i].StreetOfficeHousNumber);
                SoShopNumber += Number(accordionJson[i].StreetOfficeShopNumber);
                ANumber += Number(accordionJson[i].ANumber);
                PNumber += Number(accordionJson[i].PNumber);
                Zzs += Number(accordionJson[i].Zzs);
                Fcs += Number(accordionJson[i].Fcs);
                Grsds += Number(accordionJson[i].Grsds);
                Cjs += Number(accordionJson[i].Cjs);
                Jyffj += Number(accordionJson[i].Jyffj);
                Dfjyfj += Number(accordionJson[i].Dfjyfj);
                Yhs += Number(accordionJson[i].Yhs);
                Sljj += Number(accordionJson[i].Sljj);
                xiaoji += Number(accordionJson[i].xiaoji);
            });
            html += "<tr>";
            html += "<td hidden></td>";
            html += "<td style='color:red'>合计:</td>";
            html += "<td>" + SoHousNumber + "</td>";
            html += "<td>" + SoShopNumber + "</td>";
            html += "<td>" + ANumber + "</td>";
            html += "<td>" + PNumber + "</td>";
            html += "<td>" + Zzs.toFixed(2) + "</td>";
            html += "<td>" + Fcs.toFixed(2) + "</td>";
            html += "<td>" + Grsds.toFixed(2) + "</td>";
            html += "<td>" + Cjs.toFixed(2) + "</td>";
            html += "<td>" + Jyffj.toFixed(2) + "</td>";
            html += "<td>" + Dfjyfj.toFixed(2) + "</td>";
            html += "<td>" + Yhs.toFixed(2) + "</td>";
            html += "<td>" + Sljj.toFixed(2) + "</td>";
            html += "<td>" + xiaoji.toFixed(2) + "</td>";
            html += "</tr>";
        })
        $("#accordion").empty().append(html);
    }

    /*打开社区税收情况*/
    function openCommunityModal(StreetOfficeId) {        
        var CommunityHousNumber = 0, CommunityShopNumber = 0, ANumber = 0, PNumber = 0, Zzs = 0, Fcs = 0, Grsds = 0, Cjs = 0, Jyffj = 0, Dfjyfj = 0, Yhs = 0, Sljj = 0, xiaoji = 0;
        LayerOpen('1250px', '650px', '社区综合治税一览表', $('#CommunityModal'));//打开社区综合治税一览表
        var html = "";
        var dateWhere = $("#HiddenDate").val();
        getAjax("/ReportForms/LoadCommunityModal", { "StreetOffice_Id": StreetOfficeId, "dateWhere": dateWhere }, function (data) {
            accordionJson = eval("(" + data + ")");
            $.each(accordionJson, function (i) {
                var bianHao = i + 1;
                html += "<tr>";
                html += "<td>" + bianHao + "</td>";
                html += "<td>" + accordionJson[i].Community + "</td>";
                html += "<td>" + accordionJson[i].CommunityHousNumber + "</td>";
                html += "<td>" + accordionJson[i].CommunityShopNumber + "</td>";
                html += "<td>" + accordionJson[i].ANumber + "</td>";
                html += "<td>" + accordionJson[i].PNumber + "</td>";
                html += "<td>" + accordionJson[i].Zzs + "</td>";
                html += "<td>" + accordionJson[i].Fcs + "</td>";
                html += "<td>" + accordionJson[i].Grsds + "</td>";
                html += "<td>" + accordionJson[i].Cjs + "</td>";
                html += "<td>" + accordionJson[i].Jyffj + "</td>";
                html += "<td>" + accordionJson[i].Dfjyfj + "</td>";
                html += "<td>" + accordionJson[i].Yhs + "</td>";
                html += "<td>" + accordionJson[i].Sljj + "</td>";
                html += "<td>" + accordionJson[i].xiaoji + "</td>";
                html += "</tr>";
                CommunityHousNumber += Number(accordionJson[i].CommunityHousNumber);
                CommunityShopNumber += Number(accordionJson[i].CommunityShopNumber);
                ANumber += Number(accordionJson[i].ANumber);
                PNumber += Number(accordionJson[i].PNumber);
                Zzs += Number(accordionJson[i].Zzs);
                Fcs += Number(accordionJson[i].Fcs);
                Grsds += Number(accordionJson[i].Grsds);
                Cjs += Number(accordionJson[i].Cjs);
                Jyffj += Number(accordionJson[i].Jyffj);
                Dfjyfj += Number(accordionJson[i].Dfjyfj);
                Yhs += Number(accordionJson[i].Yhs);
                Sljj += Number(accordionJson[i].Sljj);
                xiaoji += Number(accordionJson[i].xiaoji);
            });
            html += "<tr>";
            html += "<td></td>";
            html += "<td style='color:red'>合计:</td>";
            html += "<td>" + CommunityHousNumber + "</td>";
            html += "<td>" + CommunityShopNumber + "</td>";
            html += "<td>" + ANumber + "</td>";
            html += "<td>" + PNumber + "</td>";
            html += "<td>" + Zzs.toFixed(2) + "</td>";
            html += "<td>" + Fcs.toFixed(2) + "</td>";
            html += "<td>" + Grsds.toFixed(2) + "</td>";
            html += "<td>" + Cjs.toFixed(2) + "</td>";
            html += "<td>" + Jyffj.toFixed(2) + "</td>";
            html += "<td>" + Dfjyfj.toFixed(2) + "</td>";
            html += "<td>" + Yhs.toFixed(2) + "</td>";
            html += "<td>" + Sljj.toFixed(2) + "</td>";
            html += "<td>" + xiaoji.toFixed(2) + "</td>";
            html += "</tr>";
        })
        $("#accordion1").empty().append(html);
    }
    /*街道办导出*/
    $("#btnExport").click(function () {
        layer.open({
            type: 1,
            title: '导出提示',
            shade: false,
            skin: 'layui-layer-rim',
            area: ['620px', '350px'], //宽高
            content: $('#exportHtml')
        });
    });
    /*街道办导出确定*/
    $("#btnExportSure").click(function () {
        var arr = new Array();
        $("[name='chk_list']").each(function () {
            if ($(this).is(":checked")) {
                arr.push($(this).attr("id") + "|" + $(this).val());
            }
        });
        $("#GIS_StatisticalTableMeg").val(arr);
        document.getElementById('formDownload').submit();
        layer.closeAll();
    });

    /*社区导出（街道办详情导出）*/
    $("#btnCommunityExport").click(function () {
        layer.open({
            type: 1,
            title: '导出提示',
            shade: false,
            skin: 'layui-layer-rim',
            area: ['620px', '350px'], //宽高
            content: $('#CommunityexportHtml')
        });
    });

    /*社区导出确定*/
    $("#btnCommunityExportSure").click(function () {
        var arr = new Array();
        $("[name='Communitychk_list']").each(function () {
            if ($(this).is(":checked")) {
                arr.push($(this).attr("id") + "|" + $(this).val());
            }
        });
        $("#GIS_CommunityStatisticalTableMeg").val(arr);
        document.getElementById('CommunitformDownload').submit();
        layer.closeAll();
    });

    /**
   *   日期选择器---查询租赁日期
   */
    laydate.skin('molv');         //日历皮肤
    var startS = {                   //开始时间选择
        elem: "#Search_StartTime",
        format: "YYYY/MM/DD",
        min: '1900-01-01',
        max: "2099-06-16",
        istime: false,
        istoday: true,
        choose: function (datas) {
            end.min = datas;
            end.start = datas
        }
    };
    var endS = {                     //结束时间选择
        elem: "#Search_EndTime",
        format: "YYYY/MM/DD",
        min: '1900-01-01',
        max: "2099-06-16",
        istime: false,
        istoday: true,
        choose: function (datas) { start.max = datas }
    };
    laydate(startS);
    laydate(endS);


    /*查询*/

    $("#btnSearch").click(function () {
        LayerOpen('900px', '150px', '查询', $('#ModalSearch'));
    });
    /*确定查询*/
    $("#btnSubmit").click(function () {
        var inputStateDate = $("#Search_StartTime").val();  //查询开始日期
        var inputEndDate = $("#Search_EndTime").val(); //查询结束日期
        //如果结束时间大于当前时间，则默认为当前时间
        var nowFullDate = new Date();   
        var nowDate = nowFullDate.toLocaleDateString(); //获取当前时间
                 
        if (inputStateDate == "")
        {
            layer.msg("请输入查询起始时间！", 0);
            return;
        }
        if (inputEndDate == "") {
            layer.msg("请输入查询结束时间！", 0);
            return;
        }
        
        if (new Date(inputStateDate.replace(/\-/g, "\/")) > new Date(inputEndDate.replace(/\-/g, "\/")))
        {
            layer.msg("开始时间不能大于结束时间！", 0);
            return;
        }

        if (new Date(inputEndDate.replace(/\-/g, "\/")) > new Date(nowDate.replace(/\-/g, "\/")))
        {
            inputEndDate = nowDate;  
        }
        //给条件导出赋值
        document.getElementById("where").value = inputStateDate + "," + inputEndDate;
        document.getElementById("Communitywhere").value = inputStateDate + "," + inputEndDate;     
        //社区条件赋值
        document.getElementById("HiddenDate").value = inputStateDate + "," + inputEndDate;
        StreetOfficeInfo(inputStateDate, inputEndDate);  //根据日期获取列表加载数据
        layer.closeAll();
    });

</script>